package my.mybatis.common.util.validation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @Author:wangbin.
 * @Description.   此处必须要实现ConstraintValidator接口，
 * FileValidatorAnnotation 为自定义的注解类型
 * String 为要校验的字段类型
 * @Date:Created in 14:07 2017/10/24.
 * @Modified By:
 */
public class FileValidatorAnnotationImpl implements ConstraintValidator<FileValidatorAnnotation,String> {
    private static final Logger LOGGER = LoggerFactory.getLogger(FileValidatorAnnotationImpl.class);

    public void initialize(FileValidatorAnnotation constraintAnnotation) {
        // 此处可以通过参数获取定义在注解中的属性
        LOGGER.info(constraintAnnotation.message());
    }

    public boolean isValid(String value, ConstraintValidatorContext context) {
        // value:为要检验的值
        // ConstraintValidatorContext:
        return false;
    }
}
